.class Lcom/openfeint/api/resource/CloudStorage$1;
.super Lcom/openfeint/internal/request/JSONRequest;
.source "CloudStorage.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/openfeint/api/resource/CloudStorage;->list(Lcom/openfeint/api/resource/CloudStorage$ListCB;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field private final synthetic val$cb:Lcom/openfeint/api/resource/CloudStorage$ListCB;

.field private final synthetic val$path:Ljava/lang/String;


# direct methods
.method constructor <init>(Ljava/lang/String;Lcom/openfeint/api/resource/CloudStorage$ListCB;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 1
    iput-object p1, p0, Lcom/openfeint/api/resource/CloudStorage$1;->val$path:Ljava/lang/String;

    iput-object p2, p0, Lcom/openfeint/api/resource/CloudStorage$1;->val$cb:Lcom/openfeint/api/resource/CloudStorage$ListCB;

    .line 72
    invoke-direct {p0}, Lcom/openfeint/internal/request/JSONRequest;-><init>()V

    return-void
.end method


# virtual methods
.method public method()Ljava/lang/String;
    .locals 1

    .prologue
    .line 75
    const-string v0, "GET"

    return-object v0
.end method

.method public onFailure(Ljava/lang/String;)V
    .locals 1
    .parameter "reason"

    .prologue
    .line 114
    iget-object v0, p0, Lcom/openfeint/api/resource/CloudStorage$1;->val$cb:Lcom/openfeint/api/resource/CloudStorage$ListCB;

    if-eqz v0, :cond_0

    .line 115
    iget-object v0, p0, Lcom/openfeint/api/resource/CloudStorage$1;->val$cb:Lcom/openfeint/api/resource/CloudStorage$ListCB;

    invoke-virtual {v0, p1}, Lcom/openfeint/api/resource/CloudStorage$ListCB;->onFailure(Ljava/lang/String;)V

    .line 117
    :cond_0
    return-void
.end method

.method public onSuccess(Ljava/lang/Object;)V
    .locals 1
    .parameter "responseBody"

    .prologue
    .line 108
    iget-object v0, p0, Lcom/openfeint/api/resource/CloudStorage$1;->val$cb:Lcom/openfeint/api/resource/CloudStorage$ListCB;

    if-eqz v0, :cond_0

    .line 109
    iget-object v0, p0, Lcom/openfeint/api/resource/CloudStorage$1;->val$cb:Lcom/openfeint/api/resource/CloudStorage$ListCB;

    check-cast p1, Ljava/util/List;

    .end local p1
    invoke-virtual {v0, p1}, Lcom/openfeint/api/resource/CloudStorage$ListCB;->onSuccess(Ljava/util/List;)V

    .line 111
    :cond_0
    return-void
.end method

.method protected parseJson([B)Ljava/lang/Object;
    .locals 9
    .parameter "bodyStream"

    .prologue
    .line 78
    invoke-static {p1}, Lcom/openfeint/internal/Util;->getObjFromJson([B)Ljava/lang/Object;

    move-result-object v4

    .line 79
    .local v4, o:Ljava/lang/Object;
    if-eqz v4, :cond_0

    instance-of v6, v4, Lcom/openfeint/internal/resource/ServerException;

    if-eqz v6, :cond_0

    move-object v6, v4

    .line 103
    :goto_0
    return-object v6

    .line 82
    :cond_0
    new-instance v3, Lorg/codehaus/jackson/JsonFactory;

    invoke-direct {v3}, Lorg/codehaus/jackson/JsonFactory;-><init>()V

    .line 84
    .local v3, jsonFactory:Lorg/codehaus/jackson/JsonFactory;
    :try_start_0
    invoke-virtual {v3, p1}, Lorg/codehaus/jackson/JsonFactory;->createJsonParser([B)Lorg/codehaus/jackson/JsonParser;

    move-result-object v2

    .line 87
    .local v2, jp:Lorg/codehaus/jackson/JsonParser;
    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->nextToken()Lorg/codehaus/jackson/JsonToken;

    move-result-object v6

    sget-object v7, Lorg/codehaus/jackson/JsonToken;->START_OBJECT:Lorg/codehaus/jackson/JsonToken;

    if-eq v6, v7, :cond_1

    new-instance v6, Lorg/codehaus/jackson/JsonParseException;

    const-string v7, "Couldn\'t find toplevel wrapper object."

    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getTokenLocation()Lorg/codehaus/jackson/JsonLocation;

    move-result-object v8

    invoke-direct {v6, v7, v8}, Lorg/codehaus/jackson/JsonParseException;-><init>(Ljava/lang/String;Lorg/codehaus/jackson/JsonLocation;)V

    throw v6
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 99
    .end local v2           #jp:Lorg/codehaus/jackson/JsonParser;
    :catch_0
    move-exception v6

    move-object v0, v6

    .line 100
    .local v0, e:Ljava/lang/Exception;
    sget-object v6, Lcom/openfeint/api/resource/CloudStorage$1;->TAG:Ljava/lang/String;

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v7

    invoke-static {v6, v7}, Lcom/openfeint/internal/OpenFeintInternal;->log(Ljava/lang/String;Ljava/lang/String;)V

    .line 103
    new-instance v6, Lcom/openfeint/internal/resource/ServerException;

    const-string v7, "JSONError"

    const-string v8, "Unexpected response format"

    invoke-direct {v6, v7, v8}, Lcom/openfeint/internal/resource/ServerException;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    .line 88
    .end local v0           #e:Ljava/lang/Exception;
    .restart local v2       #jp:Lorg/codehaus/jackson/JsonParser;
    :cond_1
    :try_start_1
    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->nextToken()Lorg/codehaus/jackson/JsonToken;

    move-result-object v6

    sget-object v7, Lorg/codehaus/jackson/JsonToken;->FIELD_NAME:Lorg/codehaus/jackson/JsonToken;

    if-eq v6, v7, :cond_2

    new-instance v6, Lorg/codehaus/jackson/JsonParseException;

    const-string v7, "Couldn\'t find toplevel wrapper object."

    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getTokenLocation()Lorg/codehaus/jackson/JsonLocation;

    move-result-object v8

    invoke-direct {v6, v7, v8}, Lorg/codehaus/jackson/JsonParseException;-><init>(Ljava/lang/String;Lorg/codehaus/jackson/JsonLocation;)V

    throw v6

    .line 89
    :cond_2
    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getText()Ljava/lang/String;

    move-result-object v1

    .line 90
    .local v1, hopefullyCloudStorages:Ljava/lang/String;
    const-string v6, "save_cards"

    invoke-virtual {v1, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v6

    if-nez v6, :cond_3

    new-instance v6, Lorg/codehaus/jackson/JsonParseException;

    const-string v7, "Couldn\'t find toplevel wrapper object."

    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getTokenLocation()Lorg/codehaus/jackson/JsonLocation;

    move-result-object v8

    invoke-direct {v6, v7, v8}, Lorg/codehaus/jackson/JsonParseException;-><init>(Ljava/lang/String;Lorg/codehaus/jackson/JsonLocation;)V

    throw v6

    .line 91
    :cond_3
    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->nextToken()Lorg/codehaus/jackson/JsonToken;

    move-result-object v6

    sget-object v7, Lorg/codehaus/jackson/JsonToken;->START_ARRAY:Lorg/codehaus/jackson/JsonToken;

    if-eq v6, v7, :cond_4

    new-instance v6, Lorg/codehaus/jackson/JsonParseException;

    const-string v7, "Couldn\'t find savecard array."

    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getTokenLocation()Lorg/codehaus/jackson/JsonLocation;

    move-result-object v8

    invoke-direct {v6, v7, v8}, Lorg/codehaus/jackson/JsonParseException;-><init>(Ljava/lang/String;Lorg/codehaus/jackson/JsonLocation;)V

    throw v6

    .line 92
    :cond_4
    new-instance v5, Ljava/util/ArrayList;

    invoke-direct {v5}, Ljava/util/ArrayList;-><init>()V

    .line 93
    .local v5, rv:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/String;>;"
    :goto_1
    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->nextToken()Lorg/codehaus/jackson/JsonToken;

    move-result-object v6

    sget-object v7, Lorg/codehaus/jackson/JsonToken;->END_ARRAY:Lorg/codehaus/jackson/JsonToken;

    if-ne v6, v7, :cond_5

    move-object v6, v5

    .line 98
    goto/16 :goto_0

    .line 94
    :cond_5
    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getCurrentToken()Lorg/codehaus/jackson/JsonToken;

    move-result-object v6

    sget-object v7, Lorg/codehaus/jackson/JsonToken;->VALUE_STRING:Lorg/codehaus/jackson/JsonToken;

    if-eq v6, v7, :cond_6

    new-instance v6, Lorg/codehaus/jackson/JsonParseException;

    const-string v7, "Unexpected non-string in savecard array."

    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getTokenLocation()Lorg/codehaus/jackson/JsonLocation;

    move-result-object v8

    invoke-direct {v6, v7, v8}, Lorg/codehaus/jackson/JsonParseException;-><init>(Ljava/lang/String;Lorg/codehaus/jackson/JsonLocation;)V

    throw v6

    .line 95
    :cond_6
    invoke-virtual {v2}, Lorg/codehaus/jackson/JsonParser;->getText()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_1
.end method

.method public path()Ljava/lang/String;
    .locals 1

    .prologue
    .line 74
    iget-object v0, p0, Lcom/openfeint/api/resource/CloudStorage$1;->val$path:Ljava/lang/String;

    return-object v0
.end method

.method public wantsLogin()Z
    .locals 1

    .prologue
    .line 73
    const/4 v0, 0x1

    return v0
.end method
